home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / Timer.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  3.4 KB  |  165 lines

  1. package javax.swing;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.io.Serializable;
  6. import java.util.EventListener;
  7. import javax.swing.event.EventListenerList;
  8.  
  9. public class Timer implements Serializable {
  10.    protected EventListenerList listenerList = new EventListenerList();
  11.    private boolean notify = false;
  12.    int initialDelay;
  13.    int delay;
  14.    boolean repeats = true;
  15.    boolean coalesce = true;
  16.    Runnable doPostEvent = null;
  17.    private static boolean logTimers;
  18.    long expirationTime;
  19.    Timer nextTimer;
  20.    boolean running;
  21.    private String actionCommand;
  22.  
  23.    public Timer(int var1, ActionListener var2) {
  24.       this.delay = var1;
  25.       this.initialDelay = var1;
  26.       this.doPostEvent = new DoPostEvent(this);
  27.       if (var2 != null) {
  28.          this.addActionListener(var2);
  29.       }
  30.  
  31.    }
  32.  
  33.    public void addActionListener(ActionListener var1) {
  34.       this.listenerList.add(ActionListener.class, var1);
  35.    }
  36.  
  37.    public void removeActionListener(ActionListener var1) {
  38.       this.listenerList.remove(ActionListener.class, var1);
  39.    }
  40.  
  41.    public ActionListener[] getActionListeners() {
  42.       return (ActionListener[])this.listenerList.getListeners(ActionListener.class);
  43.    }
  44.  
  45.    protected void fireActionPerformed(ActionEvent var1) {
  46.       Object[] var2 = this.listenerList.getListenerList();
  47.  
  48.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  49.          if (var2[var3] == ActionListener.class) {
  50.             ((ActionListener)var2[var3 + 1]).actionPerformed(var1);
  51.          }
  52.       }
  53.  
  54.    }
  55.  
  56.    public <T extends EventListener> T[] getListeners(Class<T> var1) {
  57.       return (T[])this.listenerList.getListeners(var1);
  58.    }
  59.  
  60.    TimerQueue timerQueue() {
  61.       return TimerQueue.sharedInstance();
  62.    }
  63.  
  64.    public static void setLogTimers(boolean var0) {
  65.       logTimers = var0;
  66.    }
  67.  
  68.    public static boolean getLogTimers() {
  69.       return logTimers;
  70.    }
  71.  
  72.    public void setDelay(int var1) {
  73.       if (var1 < 0) {
  74.          throw new IllegalArgumentException("Invalid delay: " + var1);
  75.       } else {
  76.          this.delay = var1;
  77.       }
  78.    }
  79.  
  80.    public int getDelay() {
  81.       return this.delay;
  82.    }
  83.  
  84.    public void setInitialDelay(int var1) {
  85.       if (var1 < 0) {
  86.          throw new IllegalArgumentException("Invalid initial delay: " + var1);
  87.       } else {
  88.          this.initialDelay = var1;
  89.       }
  90.    }
  91.  
  92.    public int getInitialDelay() {
  93.       return this.initialDelay;
  94.    }
  95.  
  96.    public void setRepeats(boolean var1) {
  97.       this.repeats = var1;
  98.    }
  99.  
  100.    public boolean isRepeats() {
  101.       return this.repeats;
  102.    }
  103.  
  104.    public void setCoalesce(boolean var1) {
  105.       boolean var2 = this.coalesce;
  106.       this.coalesce = var1;
  107.       if (!var2 && this.coalesce) {
  108.          this.cancelEvent();
  109.       }
  110.  
  111.    }
  112.  
  113.    public boolean isCoalesce() {
  114.       return this.coalesce;
  115.    }
  116.  
  117.    public void setActionCommand(String var1) {
  118.       this.actionCommand = var1;
  119.    }
  120.  
  121.    public String getActionCommand() {
  122.       return this.actionCommand;
  123.    }
  124.  
  125.    public void start() {
  126.       this.timerQueue().addTimer(this, System.currentTimeMillis() + (long)this.getInitialDelay());
  127.    }
  128.  
  129.    public boolean isRunning() {
  130.       return this.timerQueue().containsTimer(this);
  131.    }
  132.  
  133.    public void stop() {
  134.       this.timerQueue().removeTimer(this);
  135.       this.cancelEvent();
  136.    }
  137.  
  138.    public void restart() {
  139.       this.stop();
  140.       this.start();
  141.    }
  142.  
  143.    synchronized void cancelEvent() {
  144.       this.notify = false;
  145.    }
  146.  
  147.    synchronized void post() {
  148.       if (!this.notify || !this.coalesce) {
  149.          this.notify = true;
  150.          SwingUtilities.invokeLater(this.doPostEvent);
  151.       }
  152.  
  153.    }
  154.  
  155.    // $FF: synthetic method
  156.    static boolean access$000() {
  157.       return logTimers;
  158.    }
  159.  
  160.    // $FF: synthetic method
  161.    static boolean access$100(Timer var0) {
  162.       return var0.notify;
  163.    }
  164. }
  165.